#include<stdlib.h>
#include<iostream>

using namespace std;

#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int Status;
typedef int ElemType; 
 
typedef struct LNode
{   
	ElemType data;    
	struct LNode *next;    
} LNode, *LinkList;    



void CreateList_R(LinkList &L)
{
	int n;
	LinkList p;
	
	L = new LNode;
	L->next = NULL;
	cin>>n;
	
	while (n != -1)
	{
		p = new LNode;
		p->data = n;
		p->next = L->next;
		L->next = p;
		cin>>n;
	}
}
 
 
 
void PrintList(LinkList &L)
{
	LinkList p;

	p = L->next;

	while (p)
	{
		cout<<p->data <<" ";
		p = p->next;
	}

	cout<<endl;

}



int main()
{
	LinkList L;
	CreateList_R(L);
	PrintList(L);
	return 0;
}



